<?php get_header(); ?>
		<!-- Container Begin-->
        <div class="container">
            <!-- Content Begin-->
            <div class="content">
            	<!-- Site Navigation begin -->
                <div class="breadcrumb">
                	<?php include (TEMPLATEPATH . '/breadcrumb.php'); ?>
                </div>
                <!-- Site Navigation end -->
            	<!-- Post Content begin -->
                <div class="content_post">
					<?php if (have_posts()) : ?>
						<?php while (have_posts()) : the_post(); ?>
                        <div class="post" id="post-<?php the_ID(); ?>">
                            <h1 class="title_mid"><?php the_title() ?></h1>
                            <div class="sub_info_mid"> </div>
                            <div class="post-content"><?php the_content(''); ?></div>
                            <div class="clear"></div>
                            <?php if (get_option('wpyou_products_id')){
								$productsCats = get_option('wpyou_products_id');
								$productsArrays = explode(",",$productsCats);
							} ?>
                            <?php
								if(in_category($productsArrays) || post_is_in_descendant_category( $productsArrays )){ 
							?>
                            	<div class="the_related">
                                <h3>相关产品</h3>
                                <ul>
                                    <?php if (get_option('wpyou_news_id')) { $newsid = get_option('wpyou_news_id'); } ?>
                                    <?php
                                        $tags = wp_get_post_tags($post->ID);
                                        if ($tags) {
                                            $tag_ids = array();
                                            foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
                                        
                                            $args=array(
                                                'tag__in' => $tag_ids,
                                                'post__not_in' => array($post->ID),
                                                'showposts' => 8, // Number of related posts that will be shown.
                                                'cat' => -$newsid,
                                                'caller_get_posts' => 1
                                            );
                                            $my_query = new wp_query($args);
                                            if( $my_query->have_posts() ) {
                                                while ($my_query->have_posts()) {
                                                    $my_query->the_post();
                                                ?>
                                                    <li>
                                                        <?php if ( get_post_meta($post->ID, 'thumbnail', true) ) { ?>  
															<?php $thumbnail = get_post_meta($post->ID, 'thumbnail', true); ?>
                                                                <a title="<?php the_title(); ?>" href="<?php the_permalink() ?>"><img src="<?php echo $thumbnail; ?>" alt="<?php the_title(); ?>" title="<?php the_title(); ?>" /> </a>  
                                                        <?php
                                                             } elseif ( (function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) {
                                                        ?>
                                                                <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" ><img src="<?php $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 160,145 ), false); echo $thumbnail[0]; ?>" alt="<?php the_title(); ?>" title="<?php the_title(); ?>" /></a>
                                                        <?php } else {?>
                                                                <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" ><img src="<?php echo catch_post_image(); ?>" alt="<?php the_title(); ?>" title="<?php the_title(); ?>" /></a>
                                                        <?php } ?>
                                                        <h4><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h4>
                                                    </li>
                                                <?php
                                                }
                                            }
                                        } else {
                                            echo"<li style='text-align:left; height:24px;'>没有相关产品</li>";
                                        }
                                        ?>
                                    </ul>
                                    <?php wp_reset_query(); ?>
                            </div>
                            <?php } else { ?>
                            	<div class="the_related the_relatednews">
                                <h3>相关文章</h3>
                                <ul>
                                    <?php if (get_option('wpyou_news_id')) { $newsid = get_option('wpyou_news_id'); } ?>
                                    <?php
                                        $tags = wp_get_post_tags($post->ID);
                                        if ($tags) {
                                            $tag_ids = array();
                                            foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
                                        
                                            $args=array(
                                                'tag__in' => $tag_ids,
                                                'post__not_in' => array($post->ID),
                                                'showposts' => 8, // Number of related posts that will be shown.
                                                'cat' => -$newsid,
                                                'caller_get_posts' => 1
                                            );
                                            $my_query = new wp_query($args);
                                            if( $my_query->have_posts() ) {
                                                while ($my_query->have_posts()) {
                                                    $my_query->the_post();
                                                ?>
                                                    <li class="png">
                                                        <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a><span><?php the_time('Y-m-d') ?></span>
                                                    </li>
                                                <?php
                                                }
                                            }
                                        } else {
                                            echo"<li>没有相关文章</li>";
                                        }
                                        ?>
                                    </ul>
                                    <?php wp_reset_query(); ?>
                            </div>
                            <?php } ?>
                            <div class="clear"></div>
                            <div class="post_function">
                            	<?php comments_template(); ?>
                            </div>
                        </div>
                        <?php endwhile; ?>
                    <?php else : ?>
                        <div class="post">
                        	<strong>暂无相关文章</strong><br />
                            <p><a href="<?php echo get_settings('home'); ?>">返回首页<?php echo $langblog;?></a></p>
                        </div>
                    <?php endif; ?>
                </div>
                <!-- Post Content end -->
            </div>
            <!-- Content end-->
            <!-- Sidebar Begin-->
            <?php include (TEMPLATEPATH . '/sidebar.php'); ?>
        	<!-- Sidebar end-->
        </div>
        <!-- Container end-->
<?php get_footer(); ?>